﻿using System;

delegate void NotifyCalculation(int x, int y, int result);

class Calculator
{
    NotifyCalculation calcListener;
    public Calculator(NotifyCalculation listener)
    {
        calcListener = listener;
    }

    public int CalculateProduct(int num1, int num2)
    {
        int result = num1 * num2;
        calcListener(num1, num2, result);
        return result;
    }
}

class CalculationListener
{
    public static void CalculationPrinter(int x, int y, int result)
    {
        Console.WriteLine("Calculation Notification: {0} * {1} = {2}", x, y, result);
    }
}

class delegatedemo1
{
    static void Main(string[] args)
    {
        Calculator calc =new Calculator(CalculationListener.CalculationPrinter);

        calc.CalculateProduct(29, 32);
        calc.CalculateProduct(13, 32);
        calc.CalculateProduct(14, 29);

        Console.WriteLine("Press enter to finish");
        Console.ReadKey();
    }
}